package com.example.monitoringsystem.utils;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.logging.SimpleFormatter;

public class DateUtils {
    public static Date getCurrentSqlDate(){
        TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
        Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
        return new java.sql.Date(calendar.getTime().getYear(),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH));
    }

    public static String toString(java.util.Date date){
        String str = "yyyy-MM-dd";
        String s = new SimpleDateFormat(str).format(date);
        return s;
    }

}
